A software-defined networking (SDN) is constituted by devices such as multiple controllers and multiple switches. When receiving a data packet, a switch searches for, according to header information of the data packet, a forwarding entry included in a forwarding table, where the header information includes address information required for sending the data packet, and the address information includes at least one or more of a source Internet Protocol (IP) address, a destination IP address, a media access control (MAC) address of a source device, a MAC address of a destination device, a virtual local area network (VLAN) identifier corresponding to the source device, and a VLAN identifier corresponding to the destination device that are required for sending the data packet. If a forwarding entry that matches the header information of the data packet is found, the data packet is forwarded according to path information recorded by the forwarding entry.
If a forwarding entry that matches the header information of the data packet is not found, the first switch (for ease of description, the switch is referred to as a first switch) sends the header information of the data packet to each controller in the SDN network. Each controller in the SDN network receives the header information that is of the data packet and sent by the first switch, computes a forwarding path for the data packet according to a network topology and the header information of the data packet, and sends the computed forwarding path to switches on the forwarding path (the switches on the forwarding path include the first switch). Each controller in the SDN network computes the forwarding path of the data packet according to the foregoing method, and sends the computed forwarding path to each switch on the forwarding path (the switches on each forwarding path include the first switch). The first switch selects one forwarding path from the received forwarding paths, and forwards, according to the forwarding path, the data packet to a device corresponding to a next hop. The device corresponding to the next hop may be a switch or a terminal. If the device is a switch, the switch selects one forwarding path from the received forwarding paths, and forwards the data packet to a device corresponding to a next hop according to the selected forwarding path. In this way, the data packet is forwarded from one switch to another switch until the data packet is sent to a terminal.
In a process of implementing the present disclosure, the inventor finds that at least the following problems exist in the prior art:
Because of a real-time difference of network statuses, different controllers may have different network topologies. Therefore, forwarding paths computed by different controllers may be different, and further forwarding paths selected by different switches may be different. Therefore, when different switches forward a data packet according to different forwarding paths, a loop may be formed, causing a data packet sending failure.